package com.he.DesignPatterns.builder.demo2;

/**
 * @description: TODO
 * @Author: HCL
 * @Date: 2024/8/26 14:10
 */
public class Phone {

    private String cpu;
    private String screen;
    private String memory;
    private String mainBoard;

    private Phone(Builder builder){
        this.cpu = builder.cpu;
        this.screen = builder.screen;
        this.memory = builder.memory;
        this.mainBoard = builder.mainBoard;
    }

    public static final class Builder{
        private String cpu;
        private String screen;
        private String memory;
        private String mainBoard;

        public Builder cpu(String cpu){
            this.cpu = cpu;
            return this;
        }
        public Builder screen(String screen){
            this.cpu = screen;
            return this;
        }
        public Builder memory(String memory){
            this.cpu = memory;
            return this;
        }
        public Builder mainBoard(String mainBoard){
            this.cpu = mainBoard;
            return this;
        }

        //创建构建者对象获取phone对象
        public Phone build(){
            return new Phone(this);
        }
    }
}
